<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>商品--搜索</title>
</head>
{include file="public/href" /}
<body>
<div class="wrap-goods">
    <div class="header">
        <img src="__STATIC__/img_user/back.png" class="back" onclick=window.location.href="{:url('mobile/user_category/index')}?cate_id=recommend">
        <div>
            <input type="search" id="search" value="{:input('search','')}" placeholder="请输入搜索关键字">
            <img src="__STATIC__/img_user/fl-sousuotubiao.png" onclick="search()">
        </div>
        <img src="__STATIC__/img_user/ss-paixu.png" class="type" onclick="sort()">
        <input type="hidden" id="good_type" value="{:input('id',-1)}">
    </div>
    <div class="category">
        <ul>
            <li {eq name=":input('type',0)" value="0"}class="cur"{/eq}><div><a href="javascript:jump(0);"><span>综合</span></a></div></li>
            <li {eq name=":input('type')" value="1"}class="cur"{/eq}><div><a href="javascript:jump(1);"><span>销量</span></a></div></li>
            <li {if condition="input('type') eq 2 || input('type') eq 3" }class="cur"{/if}><div><a {eq name=":input('type')" value="2"} href="?shop_id={:input('shop_id')}&type=3&id={:input('id',-1)}" {else/} href="?shop_id={:input('shop_id')}&type=2" {/eq}><span>价格</span>
            <img {eq name=":input('type',0)" value="2"}
                 src="__STATIC__/img_user/7.png"
                 {else/}
            {eq name=":input('type',0)" value='3'}
            src="__STATIC__/img_user/fl-shangtubiao.png"
            {else/}
            src="__STATIC__/img_user/fl-shangxia.png"
            {/eq}
            {/eq}></a></div></li>
            <li><div><a href="{:url('mobile/user_category/goods_shai')}"><span>筛选</span></a></div></li>
        </ul>
        <input type="hidden" id="type"  value="{:input('type',0)}" />
        <input type="hidden" id="cate_id"  value="{:input('id','')}" />
        <ul class="list"></ul>
        <div class="style_1" style="display:none;">
        </div>
    </div>
</div>
</body>
{include file="public/src" /}
<script>
    //页面排序
    function sort(){
        var status = $('.list').css('display');
        if (status == 'none'){
            $('.list').css('display','block');
            $('.style_1').css('display','none');
        }else{
            $('.list').css('display','none');
            $('.style_1').css('display','block');
        }
    }
    //layer流加载
    layui.use('flow', function() {
        var $ = layui.jquery;
        var flow = layui.flow;
        flow.load({
            elem: '.list' //流加载容器
            ,isAuto:true
            ,isLazyimg:true
            ,done: function(page, next){ //执行下一页的回调
                var lis = [],
                search = $('#search').val(),
                type = $('#type').val(),
                good_type = $('#good_type').val(),
                cate_id = $('#cate_id').val();
                $.ajax({
                    url:"{:url('mobile/user_info/distribution_order')}",
                    dataType:'json',
                    type:'post',
                    data:{'page':page,'type':type,'goods_type':good_type,'cate_id':cate_id},
                    success:function(t){
                        layui.each(t.data, function(index, item){
                            var url = "{:url('mobile/user_category/goods_details')}?goods_id="+item.id;
                            lis.push('<li><a href="'+url+'"><div class="goods"><img lay-src="/'+item.thumb_img+'">' +
                                    '<p>销量 '+item.sale_number+'</p></div><h4>'+item.title+'</h4>' +
                                    '<div class="price">&yen;'+item.price+'</div><div class="qianbi"><span>周周币</span>' +
                                    '<img src="__STATIC__/img_user/sy-qianbi.png"><font class="scale">'+item.rebate_percentage+'%</font>' +
                                    '</div></a></li>');
                        });
                        next(lis.join(''), page < t.pages);
                    },
                    error: function () {
                        layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                    }
                })
            }
        });
        var flow_list = layui.flow;
        flow_list.load({
            elem: '.style_1' //流加载容器
            ,isAuto:false
            ,isLazyimg:true
            ,done: function(page, next){ //执行下一页的回调
                var lis = [],
                        search_1 = $('#search').val(),
                        type_1 = $('#type').val(),
                        good_type_1 = $('#good_type').val();
                $.ajax({
                    url:"{:url('mobile/user_category/goods_type')}",
                    dataType:'json',
                    type:'post',
                    data:{'page':page,'search':search_1,'type':type_1,'goods_type':good_type_1},
                    success:function(t){
                        layui.each(t.data, function(index, item){
                            var url = "{:url('mobile/user_category/goods_details')}?goods_id="+item.id;
                            lis.push('<div class="content"><div class="left"><img lay-src="/'+item.thumb_img+'"></div>' +
                                    '<div class="right"><a href="'+url+'"><h4>'+item.title+'</h4></a>'+
                                    '<div class="price">&yen;'+item.price+'</div><div class="qianbi"><span>周周币</span><img src="__STATIC__/img_user/sy-qianbi.png">' +
                                    '<font class="scale">'+item.rebate_percentage+'%</font><p>销量'+item.sale_number+'</p></div></div></div>');
                        });
                        next(lis.join(''), page < t.pages);
                    },
                    error: function () {
                        layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                    }
                })
            }
        });
    });
    function jump(type) {
        var search = $('#search').val();
        var id = $('#good_type').val();
        window.location.href = "{:url('mobile/user_category/goods_type')}?type="+type+"&search="+search+"&id="+id;

    }
    //关键词搜索
    function search(){
        var type = $('#type').val(),
                search = $('#search').val(),
                id = $('#goods_type').val();
        window.location.href = "{:url('mobile/user_category/goods_type')}?type="+type+"&search="+search+"&id="+id;
    }
</script>
</html>